import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'

import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ['vue'],
    }),
    Components({
      /* options */
    }),
  ],
  server: {
    host: '0.0.0.0', // 监听所有网络接口
    port: 5173,      // 可选，指定端口号
    // strictPort: true // 可选，端口被占用时直接报错而非尝试其他端口
    proxy: {
      // https://cn.vitejs.dev/config/#server-proxy
      '/resource': {
        target: "http://test2.yeahfei.com/resource/",
        changeOrigin: true,
        rewrite: (p) => p.replace(/^\/resource/, '')
      }
    }
  },
  resolve: {
    alias: [
      {
        find: '@',
        replacement: resolve(__dirname, 'src'),
      },
    ],
  },
})
